<?php if (!defined('SERVER_ROOT')) exit('No direct script access allowed');

class quyen_Controller extends Controller {

    function __construct(){
        parent::__construct('phanquyen', 'quyen');
        $this->check_login();
        $this->view->template->menu_html =$this->CREATE_MENU();
        $this->view->template->nhacviec_html =$this->CREATE_NHAC_VIEC(); 
        $this->CHECK_QUYEN('phanquyen', 'quyen');
    }

    function main(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->dsp_all_quyen();
    }
     private function _save_filter(){
        $v_MA_MENU_filter = $this->get_post_var('cbx_MA_MENU_filter');
        return array(
            'cbx_MA_MENU_filter' => $v_MA_MENU_filter
        );
    }
     function dsp_all_quyen(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $arr_filter = $this->_save_filter();
        $VIEW_DATA['arr_filter']                   = $arr_filter;
        $VIEW_DATA['arr_all_quyen']                = $this->model->qry_all_quyen_filter($arr_filter);
        $VIEW_DATA['arr_all_menu_filter']          = $this->model->SELECT_MENU_tatca();
        $this->view->render('dsp_all_quyen', $VIEW_DATA);
    }
    public function dsp_single_quyen($MA_QUYEN){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $MA_QUYEN = replace_bad_char($MA_QUYEN);
        $VIEW_DATA['arr_single_quyen'] = $this->model->qry_single_quyen($MA_QUYEN);
        $VIEW_DATA['arr_all_menu'] = $this->model->SELECT_MENU_nothing();
        $this->view->render('dsp_single_quyen', $VIEW_DATA);
    }
    public function update_quyen(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_quyen';
        $this->model->update_quyen();
    }
    public function delete_quyen(){
        (Session::get(TIEP_DAU_NGU_SESSION.'QUAN_TRI') == 1) Or die($this->access_denied());
        $this->model->goback_url = $this->view->get_controller_url() . 'dsp_all_quyen';
        $this->model->delete_quyen();
    }
}